<!DOCTYPE html>
<html>

<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="../bootstrap-5.1.3-dist/css/bootstrap.css" rel="stylesheet">
    <script src="../bootstrap-5.1.3-dist/js/bootstrap.bundle.js"></script>
</head>
<style>
    .Scrollspy {
        width: 500px;
        /*定义宽度*/
        height: 600px;
        /*定义高度*/
        overflow: scroll;
        /*定义当内容溢出元素框时，浏览器显示滚动条以便查看其余的内容*/
    }
</style>

<body class="container">
    <h3 align="center">嵌套导航栏中的滚动监听</h3>
    <div class="row">
        <div class="col-3">
            <nav id="navbar1 " class="navbar navbar-light bg-light">
                <nav class="nav nav-pills flex-column">
                    <a class="nav-link" href="#item-1">首页</a>
                    <nav class="nav nav-pills flex-column">
                        <a class="nav-link ms-3 my-1" href="#item-1-1">精品香蕉</a>
                        <a class="nav-link ms-3 my-1" href="#item-1-2">精品苹果</a>
                    </nav>
                    <a class="nav-link" href="#item-2">最新活动</a>
                    <a class="nav-link" href="#item-3">新品上架</a>
                    <nav class="nav nav-pills flex-column">
                        <a class="nav-link ms-3 my-1" href="#item-3-1">精品蔬菜</a>
                        <a class="nav-link ms-3 my-1" href="#item-3-2">精品葡萄</a>
                    </nav>
                </nav>
            </nav>
        </div>
        <div class="col-9">
            <div data-bs-spy="scroll" data-bs-target="#navbar1" data-bs-offset="80" class="Scrollspy">
                <h4 id="item-1">首页</h4>
                <h5 id="item-1-1">精品香蕉</h5>
                <p><img src="5.jpg" alt="" class="img-fluid"></p>
                <h5 id="item-1-2">精品苹果</h5>
                <p><img src="4.jpg" alt="" class="img-fluid"></p>
                <h4 id="item-2">最新活动</h4>
                <h4 id="item-3">新品上架</h4>
                <p><img src="1.jpg" alt="" class="img-fluid"></p>
                <h5 id="item-3-1">精品蔬菜</h5>
                <p><img src="2.jpg" alt="" class="img-fluid"></p>
                <h5 id="item-3-2">精品葡萄</h5>
                <p><img src="3.jpg" alt="" class="img-fluid"></p>
            </div>
        </div>
    </div>


</body>

</html>